#ifndef __APP_MESSAGE_H__
#define __APP_MESSAGE_H__

#include "log/log.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "cJSON/cJSON.h"
typedef enum {
    TYPE_NONE,
    TYPE_BT,
    TYPE_LORA
}connection_type;

typedef struct {
    connection_type type;
    void *id;
    size_t id_len;
    void *data;
    size_t len;
}message;
//二进制串解析为消息
message* app_message_initFromBinary(void *data, size_t len);
//Json解析
message* app_message_initFromJson(char *json_str, size_t len);
//消息转化为json
int app_message_saveAsJson(message *msg, char *json_str, size_t len);
//消息转化为二进制串
int app_message_saveAsBinary(message *msg, void *data, size_t len);
//释放消息
void app_message_free(message *msg);

#endif /* __APP_MESSAGE_H__ */